package com.sesame.feign;


import kim.sesame.common.result.ApiResult;
import kim.sesame.framework.web.response.ResponseFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = FeignServiceTx3.APP_NAME, fallback = FeignServiceTx3Hystrix.class)
public interface FeignServiceTx3 {

    String APP_NAME = "DISTRIBUTED-TX-5-EXAMPLE-CH3-SERVICE";
    String SERVICE_NAME = "";

    @RequestMapping(value = SERVICE_NAME + "/user/save")
    Response save(@RequestParam("id") String id, @RequestParam("updateUser") String updateUser);

}

@Component
class FeignServiceTx3Hystrix implements FeignServiceTx3 {

    @Override
    public ApiResult save(String id, String value) {
        return ResponseFactory.feignException("update3");
    }
}